package logic

import (
	"aq/aqrpc/aqrpc"
	"aq/aqrpc/internal/svc"
	"aq/models/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAddLogic {
	return &UserAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserAddLogic) UserAdd(in *aqrpc.UserAddRequest) (*aqrpc.UserAddResponse, error) {
	// todo: add your logic here and delete this line
	user := mysql.UserRealnames{
		Name:   in.Name,
		IdCard: in.IdCard,
	}
	mysql.DB.Debug().Create(&user)

	return &aqrpc.UserAddResponse{
		UserRealnamesId: int64(user.ID),
	}, nil
}
